﻿using System;
 using System.Windows.Automation;

namespace AutoWinUI 
{
    public class PatternAction
    {
        public static void InvokePatternInvokeAction(AutomationElement element)
        {
            try
            {
                InvokePattern invPattern = (InvokePattern)element.GetCurrentPattern(InvokePattern.Pattern);
                invPattern.Invoke();
            }
            catch (System.Windows.Automation.ElementNotEnabledException)
            {
                throw;
            }
            catch (System.InvalidOperationException)
            {
                throw;
            }
        }

        public static void ValuePatternSetValue(AutomationElement element, string value)
        {
            try
            {
                ValuePattern valPattern = (ValuePattern)element.GetCurrentPattern(ValuePattern.Pattern);
                valPattern.SetValue(value);
            }
            catch (System.Windows.Automation.ElementNotEnabledException)
            {
                throw;
            }
            catch (System.InvalidOperationException)
            {
                throw;
            }
        }

        public static void TextPatternSetText(AutomationElement element, string text)
        {
            try
            { 
                TextPattern txtPattern = (TextPattern)element.GetCurrentPattern(TextPattern.Pattern);
                
            }
            catch
            { }
        }




    }
}
